﻿Public Class frmsqlquery
    Dim mysql As New ClsSQLhelper
    Dim strsql As String
    'Dim ConnHOSxP As Boolean = False
    Private Sub BtnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExecute.Click
        Try
            If Me.TxtSQLString.Text = "" Then Exit Sub
            strsql = Me.TxtSQLString.Text & " limit " & Me.NUDLimitRows.Value
            Dim DT_Result As New DataTable
            If Me.OptHOSxP.Checked = True Then
                DT_Result = mysql.GetMYSQLDataTable(strsql, "My_temptable", True)
            Else
                DT_Result = mysql.GetMYSQLDataTable(strsql, "My_temptable")
            End If



            With Me.GridResult
                .RowHeadersVisible = False
                .AllowDrop = False
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .AllowUserToOrderColumns = True
                .AllowUserToResizeColumns = True
                .AllowUserToResizeRows = False
                .MultiSelect = False
                .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells
                .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
                .DataSource = DT_Result
                TSlblRecords.Text = DT_Result.Rows.Count & " Record(s)"
            End With
            ' DT_Result.Dispose()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Dispose()
    End Sub
End Class